declare global {
  interface Error {
    isMock?: boolean
  }
}
function isMock(e: any) {
  return !!(e && e instanceof Error && e.isMock)
}

export default class BaseException extends Error {
  code: string
  originalError: Error
  constructor(e?: Error | string, code?: string) {
    super(e instanceof Error ? e.message : e)
    this.name = "BaseException"
    code && (this.code = code)
    if (e instanceof Error) {
      this.originalError = e
      isMock(e) && (this.isMock = !0)
    }
  }
}
